package org.jeecg.modules.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.system.entity.ZkEquipmentOverhaul;
import org.jeecg.modules.system.entity.ZkEquipmentOverhaulDetail;

import java.util.List;
import java.util.Map;

/**
 * @Description: 设备检修表
 * @Author: jeecg-boot
 * @Date:   2024-04-28
 * @Version: V1.0
 */
public interface ZkEquipmentOverhaulMapper extends BaseMapper<ZkEquipmentOverhaul> {
    //设备检修根据当前登录人员和时间查询
    List<ZkEquipmentOverhaul> queryPageListVo(Page<ZkEquipmentOverhaul> page, @Param("id") String id);

    /**
     * 审批界面/检修（根据当前登录人和状态分页查询）
     * @param page     分页参数
     * @param id       当前登录人
     * @return
     */
    @Select("select * from zk_equipment_overhaul_detail where aud_personnel_id=#{id} and overhaul_status=1")
    IPage<ZkEquipmentOverhaulDetail> queryZkEquipmentOverhaulDetail(Page<ZkEquipmentOverhaulDetail> page, @Param("Id") String id);

    /**
     * 发起界面/检修（根据当前登录人和状态分页查询）
     * @param page     分页参数
     * @param id       当前登录人
     * @return
     */
    @Select("select * from zk_equipment_overhaul_detail where overhaul_personnel_id=#{id} and overhaul_status=1")
    IPage<ZkEquipmentOverhaulDetail> queryZkEquipmentOverhaulList(Page<ZkEquipmentOverhaulDetail> page, @Param("Id") String id);

    /**
     * 抄送任务(检修)（根据当前登录人和状态将维修，保养，检修放在同一个分页查询中）
     */
    @Select("select * from zk_equipment_overhaul_detail where cc_personnel_id=#{id} and if_cc=1")
    IPage<ZkEquipmentOverhaulDetail> queryZkEquipmentOverhaulCc(Page<ZkEquipmentOverhaulDetail> page, @Param("Id") String id);

    /**
     * 抄送任务(检修)（根据当前登录人和状态将维修，保养，检修放在同一个分页查询中）
     */
    @Select("select * from zk_equipment_overhaul")
    List<ZkEquipmentOverhaul> queryZkEquipmentOverhaul();

    /**
     * 保养柱状图PC端首页(根据检修周期统计数量)
     */
    @Select("select count(*) as countNum ,overhaul_time as overhaulTime from zk_equipment_overhaul GROUP BY overhaul_time")
    List<Map<Integer,Integer>> pcCount();


}
